package com.EAIPClub.codeidemanager.controller;

import com.EAIPClub.codeidemanager.service.CodeIdeManagerService;
import com.api.POJO.CodeLab.CodeIdeManager.CodeIdeAccount;
import com.api.POJO.CodeLab.CodeIdeManager.CodeIdeManagerReturnMsg;
import com.api.POJO.CodeLab.CodeIdeManager.CodeIdeUserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description :CodeIde管理模块控制层
 * @Author :崔昌赫
 * @Date : 2021/10/26
 */
@RestController
public class CodeIdeManagerController {
    private CodeIdeManagerService codeIdeManagerService;

    @Autowired
    public void setCodeIdeManagerService(CodeIdeManagerService codeIdeManagerService) {
        this.codeIdeManagerService = codeIdeManagerService;
    }

    @PostMapping("/users/codelab/codeide/password")
    CodeIdeManagerReturnMsg setCodeIdePassword(@RequestBody CodeIdeAccount account){
        return codeIdeManagerService.setCodeIdePassword(account);
    }

    @PostMapping("/users/codelab/codeide/userinfo")
    CodeIdeManagerReturnMsg setCodeIdeUserInfo(@RequestBody CodeIdeUserInfo info){
        return codeIdeManagerService.setCodeIdeUserInfo(info);
    }

    @GetMapping("/users/codelab/codeide/password/uid/{uid}")
    CodeIdeManagerReturnMsg getCodeIdePassword(@PathVariable String uid){
        return codeIdeManagerService.getCodeIdePasswordByUid(uid);
    }

    @GetMapping("/users/codelab/codeide/info/uid/{uid}")
    CodeIdeManagerReturnMsg getCodeIdeInfo(@PathVariable String uid){
        return codeIdeManagerService.getCodeIdeUserInfoByUid(uid);
    }

    @GetMapping("/codelab/getnode/{node}")
    String getNodeIp(@PathVariable String node){
        return codeIdeManagerService.getNodeIp(node);
    }

    @GetMapping("/codelab/codeide/getport")
    List<String> getAllPorts(){
        return codeIdeManagerService.getAllPorts();
    }
}
